<?php
include 'includes.php';
include 'functions.php';
include 'admin-functions.php';
include 'config.php';
session_start();

if ( isset($_POST['logout'])){
	$_SESSION = array();
	session_destroy();
}
check_admin();
?>

<html xmlns="http://www.w3.org/1999/xhtml"><!-- Mirrored from themes.voodoo-pixel.com/skate/index-2.html by HTTrack Website Copier/3.x [XR&CO'2010], Fri, 16 Dec 2011 13:45:35 GMT --><head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="keywords" content="">
<meta name="description" content="">

<!--Title of your website-->
<title>Pannello Amministratore</title>

<!--CSS Styles-->
<link rel="stylesheet" type="text/css" href="css/style-1.css">
<link rel="stylesheet" type="text/css" href="css/typography.css">
<link rel="stylesheet" type="text/css" href="css/slider.css">
<link rel="stylesheet" type="text/css" href="css/prettyPhoto.css">
<link rel="stylesheet" href="css/jquery.fancybox.css?v=2.0.4" type="text/css" media="screen" />


<!--Java Script-->
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/accordion.js"></script>
<script type="text/javascript" src="js/functions.js"></script> 
<script type="text/javascript" src="js/supersubs.js"></script> 
<script type="text/javascript" src="js/superfish.js"></script> 
<script type="text/javascript" src="js/nivo-slider.js"></script>
<script type="text/javascript" src="js/jquery.prettyPhoto.js"></script>
<script type="text/javascript" src="js/jquery.fancybox.pack.js?v=2.0.4"></script>

<!-- Script e css personalizzati -->
<script type="text/javascript" src="js/jquery.numeric.js"></script>
<script type="text/javascript" src="js/jquery.validate.js"></script>
<script type="text/javascript" src="js/jquery.validation.messages_it.js"></script>
<script type="text/javascript" src="js/uploadify/swfobject.js"></script>
<script type="text/javascript" src="js/2.5.3-crypto-md5.js"></script>

<link rel="stylesheet" type="text/css" href="css/uploadify.css">

<script type="text/javascript">
// <![CDATA[
$(document).ready(function() {
  $('#file_upload').uploadify({
    'uploader'  : 'js/uploadify/uploadify.swf',
    'script'    : 'scripts/uploadify.php',
    'cancelImg' : 'images/uploadify/cancel.png',
    'folder'    : 'upload/',
    'buttonText': 'Seleziona il File',
    'fileExt'     : '*.xls',
    
    'auto'		: true
    
  });
});
// ]]>
</script>

<style type="text/css">.jlhlebbhengjlhmcjebbkambaekglhkf {top: 0px; left: 0px;min-width: 30px;max-width: 300px;font-size: 13px;font-family: arial, helvetica, sans-serif;opacity: .93;padding:0px;position:absolute;display:block;z-index: 999997;font-style: normal;font-variant: normal;font-weight: normal;}#jlhlebbhengjlhmcjebbkambaekglhkf_up{text-align: center;padding:0px;margin: 0px;}#jlhlebbhengjlhmcjebbkambaekglhkf_cont{background-color: #729FCF;font-family: arial, helvetica, sans-serif-webkit-box-shadow: #729FCF 0px 0px 2px;color: #FFFFFF;padding:7px;-webkit-border-radius: 5px;}#jlhlebbhengjlhmcjebbkambaekglhkf_down{text-align: center;padding:0px;margin: 0px;}</style></head>


<!--Body-->
<body> 

<!--Wrapper-->
<div id="wrapper">

<!--Header-->
	<div id="header">
  
<!--Logo-->
	
    
<!--Top Banner
	<div class="top-banner">
	<img src="images/demo/banners/top_banner.jpg" width="468" height="60" alt="Top-banner" />
	</div>
	-->
	
	</div>
	
	
	<ul class="sf-menu sf-js-enabled">
		<li><a href="admin.php" <?=is_current("admin.php");?>>Pannello Amministratore</a></li>
		<li><a href="admin-upload-list.php" <?=is_current("admin-upload-list.php");?>>Carica Lista Libri</a></li>
		<li><a href="admin-profile.php" <?=is_current("admin-profile.php");?>>Profilo</a></li>
		
		<li style="float:right;"><a href="#"  onclick="document.logout_form.submit()" >Logout</a></li>
		<form id="logout_form" name="logout_form" action="" method="POST">
			<input type="hidden" id="logout" name="logout"/>
		</form>
		
	</ul>
	
	
	<div id="#main-content full_width" style="background: white;">
		<div id="book_list_container">
			<h1>Informazioni account</h1>
			<p><b>Email</b></p>
			<?=$_SESSION['admin_email']?>
		
			<form id="change_password" onsubmit="return false;">
				<input type="hidden" id="email" value="<?=$_SESSION['admin_email']?>" />
				<label for="current_password"><p>Password Attuale:</p></label>
				<input type="password" id="current_password" name="current_password"  />
				<label for="new_password"><p>Nuova password:</p></label>
				<input type="password"  id="new_password" name="new_password" />
				<label for="new_password_confirm"><p>Conferma nuova password:</p></label>
				<input type="password"  id="new_password_confirm" name="new_password_confirm"/>
				<br>
				<input type ="submit" value="Invia"/>
			</form>
			
			<p id="password_change_completed"  style="display:none;color:green;">
			Password cambiata correttamente
			</p>
			<p id="error_password"  style="display:none;color:red;">
			La password deve essere lunga almeno 5 caratteri
			</p>
			
			
			
		
		
	

	

    
	</div>
</div>
<script type="text/javascript">
var validation = $("#change_password").validate({
	  rules: {
		    new_password : {
			    required:true
			    
		    },
		    current_password : {
		    	required:true
			    
		    },
		    new_password_confirm: {
		    	required:true,
		      	equalTo: "#new_password"
		      	
		    }
		  }
		});



$("#change_password").submit(function(){
	$("#error_password").hide();
	$("#password_change_completed").hide();
	
	if ( validation.form() && minlength() ){
		var email=$("#email").val();
		var curr_passwd = Crypto.MD5( $.trim($("#current_password").val() ) );
		var new_passwd = Crypto.MD5( $.trim($("#new_password").val() ) );
		var new_passwd_confirm = Crypto.MD5( $.trim($("#new_password_confirm").val() ) );
		 

		var dataSend= { current_password: curr_passwd, new_password: new_passwd, 
				new_password_confirm: new_passwd_confirm,
				email: email, request_type: "change_password" };
		$.ajax({
			  url: 'admin-ajax.php',
			  type: "POST",
			  data: dataSend,
			  dataType: "json",
			  success: function( data ) {
				  	if ( data['password_changed'] ){
					  	$("#change_password").fadeOut("slow",function(){
							$("#password_change_completed").fadeIn("slow");
							
						 });
				  	}
				  	else
						alert("problemi durante la richiesta, riprovare.");  	
				  }
		  	 
			  
			});

	}
	
});

function minlength(){
	var password = $("#current_password").val();
	var new_password = $("#new_password").val();
	if ( password.length >= 5 && new_password.length >= 5){
		return true;
	}
	$("#error_password").show();
	return false; 

	
}
</script>

<script type="text/javascript" src="https://www.google.com/jsapi?key=ABQIAAAAhsLC7op2IZocFRdmvLMBORT2yXp_ZAY8_ufC3CFXhHIE1NvwkxRst5mULoL3XKzJMdUWZMkZ2AWLVw">
</script>
<script type="text/javascript">
  google.load("jqueryui", "1.7.2");
</script>
</body>
</html>